package day0726API;

public class Test3 {

    public static void main(String[] args) {
        //1.继承Thread类
        //2.实现run方法
        Thread  t=new Thread(){
            public void run() {
                while(true){
                    try {
                        Thread.sleep(900);
                        System.out.println("卖水果");
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        } ;


        //3.调用线程的start()
        t.start();

        Thread  t2=new Thread(){
            public void run() {
                while(true){
                    try {
                        Thread.sleep(200);
                        System.out.println("卖馒头");
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        } ;

        //3.调用线程的start()
        t2.start();

    }

}
